/*
 * @Description: 
 * @Version: 2.0
 * @Autor: ftt
 * @Date: 2022-06-09 11:19:38
 * @LastEditors: TT
 * @LastEditTime: 2023-05-16 17:46:12
 */

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hzy_common_module/components/common_place_holder_widget.dart';
import 'package:hzy_common_module/config/normal_configs.dart';
import 'package:hzy_normal_tool/hzy_normal_tool.dart';
import 'common_getx_controller.dart';
import 'common_widgets.dart';

abstract class CommonGetXWidget<T extends CommonGetXController>
    extends GetView<T> with HzyAbstractAttribute, HzyAbstractWidget {
  CommonGetXWidget({Key? key}) : super(key: key);

  @override
  Color? get navbackcolor => PageNormalConfig.configNavBackColor;
  @override
  String? get title => configAppBarTitle();
  @override
  bool get safeAreabottm => false;

  @override
  bool get isAddPopScope => PageNormalConfig.configIsAddPopScope;
  @override
  Widget build(BuildContext context) {
    Widget widget = createScaffol(
      context: context,
      safeAreatop: safeAreatop,
      safeAreabottm: safeAreabottm,
      resizeToAvoidBottomInset: resizeToAvoidBottomInset,
      title: title,
      backgroundColor: backgroundColor,
      navbackcolor: navbackcolor,
      isneedScaffol: isneedScaffol,
      isAddPopScope: isAddPopScope,
    );
    return widget;
  }

  @override
  bool configIsNeedLayout() {
    return kIsWeb == true ? false : true;
  }

  @override
  createLayoutChileWidget({
    BoxConstraints? constraints,
  }) {
    return Obx(
      () => super.createLayoutChileWidget(),
    );
  }

  configAppBarTitle() {
    return controller.appBarTtitle;
  }

  @override
  Widget? createFlexBleSpace() {
    return configNavImageBg();
  }

  @override
  configPrferredheight() {
    return PageNormalConfig.configPreferredHeight;
  }

  @override
  Widget? createEmptyWidget() {
    return CommonPlaceHoldPage(
      placeHoldType: controller.placeHoldType,
      msg: controller.placeMsg,
      ontap: () {
        controller.tapPlaceHoldWidgetMethod(
          placeHoldType: controller.placeHoldType,
        );
      },
    );
  }

  @override
  configPageState() {
    return controller.pageState.value;
  }

  @override
  bool configIsshowLoading() {
    return controller.isShowLoadWidget.value;
  }

  @override
  configBoxDecoreation() {
    return PageNormalConfig.configNormalBoxDec;
  }

  @override
  Widget? createLoadingWidget() {
    return PageNormalConfig.configLoadingWidget;
  }

  @override
  Color? createAppBarTextColor() {
    return PageNormalConfig.configNormalAppBarTextColor;
  }

  @override
  Color? createLeadingIconColor() {
    return PageNormalConfig.configNormalLeadingIconColor;
  }

  @override
  Color? get backgroundColor => PageNormalConfig.configBackGroundColor;
}
